<?php
    //访问log统计
    error_reporting(E_ALL || ~E_NOTICE); //忽略警告
    date_default_timezone_set('PRC');//设置时区
    require_once("ReturnBean.php");
    require_once("mysql.php");
    require_once("RemoteInfo.php");
    $device = $_REQUEST["device"];
    $access_url = $_REQUEST["access_url"];
    if(!$device||!$access_url){
        echo json_encode(new ResultBean(501,"参数不全"),JSON_UNESCAPED_UNICODE);
        return;
    }
    $mysqlHelper = new MysqliHelper();
    $remote_info = new GetRemoteInfo();
    $ip = $remote_info->getRemoteIp();
    //获取ip信息的url目前使用淘宝的
    $ipInfo = file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=$ip");
    $ipJsonInfo = json_decode($ipInfo, true);
    $region = $ipJsonInfo["data"]["region"];
    $city = $ipJsonInfo["data"]["city"];
    $isp = $ipJsonInfo["data"]["isp"];
    $res = $mysqlHelper->insert_Tbl_access_Log("insert into tbl_access_log(access_date,access_device,access_url,ip,region,city,isp) values (?,?,?,?,?,?,?)",date("Y/m/d H:i:sa"),$device,$access_url,$ip,$region,$city,$isp);
    if($res==true){
        echo json_encode(new ResultBean(200,"success","执行成功！"),JSON_UNESCAPED_UNICODE);
        return;
    }else{
        echo json_encode(new ResultBean(401,"sqlInsertFail",$res),JSON_UNESCAPED_UNICODE);
    }
?>